x86: Fixes for S3 suspend resume:
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Jan 2008 10:13:11 +0000 (10:13 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Jan 2008 10:13:11 +0000 (10:13 +0000)
 - Fix wallclock resume by remembering the offset from CMOS time to
   UTC time
 - Restore dom0's CPU affinity (lost during
   continue_hypercall_on_cpu())

Signed-off-by: Xu Dongxiao <dongxiao.xu@intel.com>
xen/arch/x86/domain.c
xen/arch/x86/time.c

index 588a7fb1f74fc89bea255b8dbcad1fbb83792a92..957e33ef575f4bf6aac90fea1cef184750249bfd 100644 (file)
@@ -1420,6 +1420,7 @@ static void continue_hypercall_on_cpu_helper(struct vcpu *v)
     regs->eax = info->func(info->data);
 
     v->arch.schedule_tail = info->saved_schedule_tail;
+    v->cpu_affinity = info->saved_affinity;
     v->arch.continue_info = NULL;
 
     xfree(info);
index a9e2b5b7353c742e973ef1a22094f0b8a3afa324..6d4946245bd08a8419202be26ded212a11913436 100644 (file)
@@ -971,8 +971,14 @@ unsigned long get_localtime(struct domain *d)
         + d->time_offset_seconds;
 }
 
+/* "cmos_utc_offset" is the difference between UTC time and CMOS time. */
+static long cmos_utc_offset; /* in seconds */
+
 int time_suspend(void)
 {
+    cmos_utc_offset = (wc_sec + (wc_nsec + NOW()) / 1000000000ULL)
+        - get_cmos_time();
+
     /* Better to cancel calibration timer for accuracy. */
     kill_timer(&this_cpu(cpu_time).calibration_timer);
 
@@ -986,7 +992,8 @@ int time_resume(void)
     set_time_scale(&this_cpu(cpu_time).tsc_scale, tmp);
 
     resume_platform_timer();
-    do_settime(get_cmos_time(), 0, read_platform_stime());
+
+    do_settime(get_cmos_time() + cmos_utc_offset, 0, read_platform_stime());
 
     init_percpu_time();